Release 10.1A: OpenEdge Development:
Progress Dynamics Advanced Development
Retrieving related information for an object
This section outlines how you retrieve various kinds of information in the cache that is related to an object, and which completes the definition of the object.
Retrieving the instance ID for an object
Before finding any related information, you must have the instance ID (the
tRecordIdentifierfield value) of the record whose associated information you require. There are several ways of doing this.If the object is running, you can retrieve the instance ID as an object property using the ADM property include file syntax. In this example, the object handle is in the variable
hObjectand theRecord Identifieris retrieved into the variabledInstanceID:
Or you can use the equivalent function call, as shown:
Alternatively, the object that you request using
cacheObjectOnClient()is available immediately after the call to that function. You can then use a statement such as the following to return the buffer handle to thecache_Objecttemp-table, which will also be positioned to the requested record:
After finding the
cache_Objectbuffer, do aFINDbased on your own criteria to position to the relevant record. Once you have found an availablehObjectBufferrecord, you can populate thedInstanceIdvariable using a statement such as this:
Getting the instance ID is the first step to getting all the other related information out of the cache.
Retrieving other object information
To get
Page,Pageinstance, link, and UI event information for a particular object, first retrieve the buffer handle for the relevant cache buffer, using one of the functionsgetCachePageBuffer,getCachePageInstanceBuffer,getCacheLinkBuffer, orgetCacheUIEventBuffer. In this code example,hBufferis the buffer handle retrieved using one of those function calls. Create a dynamic query on that table, with aWHEREclause such as this:
Retrieving attribute values for an object
To retrieve attribute values, you first must obtain the instance ID (the
tRecordIdentifierfield value) from thecache_Objectrecord. Remember that the correctcache_Objectrecord isAVAILABLEafter a call tocacheObjectOnClient(). Otherwise, if you have the object’s instance ID, you can make a call togetCacheObjectBuffer(), passing in the instance ID. This ensures that the correct record is available to you. ThetClassBufferHandlefield contains the buffer handle of the record that contains the attributes for the object.Using a statement such as the following, you can retrieve the attributes for the specific object. Note the use of the recently introduced dynamic
FIND-FIRSTmethod on a buffer handle, which allows you to position the buffer to a record using a dynamicWHEREclause, as shown:
You can now retrieve the values for the relevant field, as shown in the code sample earlier in this section.
Retrieving an object’s contained instances
There are two primary ways of getting all the contained instances for a container object. You can query all
cache_Obectrecords where either:
- The
tContainerRecordIdentifierequals the instance ID of the container master object.- The
tContainerObjectNameequals the logical object name of the container object. This second method requires you to also include in your query the user, language, result code, and run attribute, as well as checking that the object instance object ID is zero.The first alternative is simpler and requires less programming work since all that is needed is the instance ID, which is readily available. The other information required to use the second alternative requires various calls and possibly further calculation.
How attributes are stored
Each class has its own attribute temp-table, with a field for each attribute in the class. This includes all attributes inherited by the class from its parent classes. The initial value of each attribute field is the initial or default value of the attribute for that class. The temp-table is created dynamically by
buildClassCache()and is calledcache_<ClassName>. These tables and their buffer handles are then cached in thettClasstemp-table.There are also a couple of fields which the
cache_<ClassName>table uses internally:
tRecordIdentifier— This field contains the Record or instance ID of thecache_Objectrecord to which the attributes belong.tWhereStored— This field contains an integer indicating at what level the attribute is stored (class, master, or instance) and whether customization has been applied to the attribute. ThegetWhereStoredLevelfunction returns a character description of this value for a given field within an attribute buffer.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |